package controllers

import (
	"free_convert/config"
	"free_convert/utils/logger"

	"github.com/gin-gonic/gin"
)

// file upload controller
type UploadController struct{}

/*
*
@api {post} /upload/single Upload a single file
@apiName UploadSingle
@apiDescription Upload a single file
@apiParam {File} file1 First file to upload.
*/
func (UploadController) SingleUpload(c *gin.Context) {
	file, _ := c.FormFile("file")
	logger.Info("upload file: ", file.Filename)
	// save the file to server
	dst := config.UploadDir + file.Filename
	if err := c.SaveUploadedFile(file, dst); err != nil {
		logger.Error("upload file failed: ", err)
		ReturnError(c, 500, "upload file failed")
		return
	}
	ReturnSuccess(c, 200, nil, "upload file success")
}

/*
*
@api {post} /upload/multiple Upload multiple files
@apiName UploadMultiple
@apiDescription Upload multiple files
@apiParam {File} file1 First file to upload.
*/
func (UploadController) MultipleUpload(c *gin.Context) {

}
